<?php
session_start();
if (!empty($_GET['codigo'])) {
    $id = $_GET['codigo'];
    $semestres = array("Sin Semestre","I","II","III","IV","V","VI","VII","VIII","IX","X");

}

include 'database.class.php';
$db = new Database();
$db->dbConnect();
$sql = mysql_query("SELECT
    codigo
    , nombre
    , semestre
    , direccion
    , telefonofijo
    , telefonocelular
    , correo
    , identificacion
    , apellido
    , estado
FROM
    estudiante WHERE
        codigo= $id");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="css/default.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="js/jquery-1.4.3.js"></script>
        <script type="text/javascript" src="js/jquery-ui-1.8.6.custom.min.js"></script>
        <script type="text/javascript" src="js/jquery.validate.js" ></script>
        <script type="text/javascript">
            $(document).ready(function() {
                $("#form-contacto").validate();
            });
        </script>
        <style type="text/css">
            #commentForm { width: 500px; }
            #commentForm label { width: 250px; }
            #commentForm label.error, #commentForm input.submit { margin-left: 253px; }
        </style>
        <title>Editar Estudiante</title>
    </head>
    <!--body-->
    <body>
        <div id="wrapper">
<?php include 'include/header.php'; ?>
            <!-- end div#header -->
            <div id="page">
                <div id="content">
                    <div id="welcome">
                        <h1>Editar Estudiante</h1>
                        <p><img src="images/warning.png" width="30" height="30">  El codigo del estudiante no podra ser modificado</p>

                        <div id="form-area">
                            <fieldset>
                                <h2>Editar estudiante <?php echo $id ?></h2>
                                <form action="include/actualizar-form-est.php" method="post" id="form-contacto">
<?php
while ($fila = mysql_fetch_array($sql)) {
?>
                                    <dl>
                                        <dt><label for="codigo" style="visibility: hidden">Codigo *</label></dt>
                                        <dd><input type="hidden" name="codigo" id="codigo" value="<?php echo $id ?>"/></dd>
                                        <div style="clear: both; height: 1px"></div>
                                        <dt><label for="nombre">Nombre *</label></dt>
                                        <dd><input type="text" name="nombre" id="nombre" value="<?php echo$fila["nombre"]; ?>" class="required" minlength="2"/></dd>
                                        <dt><label for="apellido">Apellido *</label></dt>
                                        <dd><input type="text" name="apellido" id="apellido" value="<?php echo$fila["apellido"]; ?>" class="required" minlength="2" /></dd>
                                        <dt><label for="doc">Documento *</label></dt>
                                        <dd><input type="text" name="doc" id="doc" value="<?php echo$fila["identificacion"]; ?>" class="digits required required" minlength="8" maxlength="20"/></dd>
                                        <dt><label for="email">Email *</label></dt>
                                        <dd><input type="text" name="email" id="email" value="<?php echo$fila["correo"]; ?>" class="required email required" minlength="7"/></dd>
                                        <dt><label for="fijo">Telefono Fijo</label></dt>
                                        <dd><input type="text" name="fijo" id="fijo" value="<?php echo$fila["telefonofijo"]; ?>" class="digits" minlength="7" maxlength="7"/></dd>
                                        <dt><label for="movil">Telefono Movil</label></dt>
                                        <dd><input type="text" name="movil" id="movil" value="<?php echo$fila["telefonocelular"]; ?>" class="digits" minlength="10" maxlength="10"/></dd>
                                        <dt><label for="dir">Direccion *</label></dt>
                                        <dd><input type="text" name="dir" id="dir" value="<?php echo$fila["direccion"]; ?>" class="required" minlength="15"/></dd>
                                        <dt><label for="estado">Estado *</label></dt>
                                        <dd>
                                            <select name="estado" id="estado" class="required">
                                                <?php
                                                if( $fila["estado"] == "1")
                                                {
                                                  echo "<option value='0'>Inactivo</option>
                                                        <option value='1' selected>Activo</option>";
                                                }else{
                                                      echo "<option value='0' selected>Inactivo</option>
                                                        <option value='1' >Activo</option>";
                                                }
                                               ?>
                                            </select>
                                        </dd>
                                        <dt><label for="semestre">Semestre *</label></dt>
                                        <dd>
                                            <select name="semestre" id="semestre" class="required">

                                                <?php

                                                  for ($index = 0; $index < count($semestres); $index++) {

                                                       if( $fila["semestre"] == $index){
                                                      
                                                            echo ("<option value='$index' selected>$semestres[$index]</option>");
                                                           
                                                       }else{

                                                          echo("<option  value='$index'>$semestres[$index]</option>");
                                                       }

                                                   }

                                                ?>
                                               
                                            </select>
                                        </dd>
                                        <dt class="center">
                                            <input type="submit" name="submit" title="Guardar" id="submit" value="" style="background-image:url(images/Save.png); width:50px; background-repeat:no-repeat; background-position:center;"/>
                                            
                                            <input type="reset" name="button" title="Restaurar"id="button" value="" style="background-image:url(images/Undo.png); width:50px; background-repeat:no-repeat; background-position:center;"/>
                                        </dt>
                                    </dl> 
<?php
                                }
?>

                                </form>
                            </fieldset>
                        </div>
                    </div>
                    <!-- end div#welcome -->
                </div>
                <!-- end div#content -->
                <div id="sidebar">
                    <ul>
<?php include 'include/nav.php'; ?>
                        <!-- end navigation -->
                    </ul>
                </div>
                <!-- end div#sidebar -->
                <div style="clear: both; height: 1px"></div>
            </div>
<?php include 'include/footer.php'; ?>
        </div>
        <!-- end div#wrapper -->
    </body>
    <!--body ends-->
</html>